package com.baymax.test.scene.demo

import android.content.res.ColorStateList
import android.graphics.Canvas
import android.graphics.Color
import android.graphics.Paint
import android.graphics.drawable.BitmapDrawable
import android.graphics.drawable.ColorDrawable
import android.graphics.drawable.Drawable
import android.graphics.drawable.GradientDrawable
import android.os.Bundle
import android.text.style.ReplacementSpan
import android.util.StateSet
import android.view.Gravity
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.core.content.ContextCompat
import com.baymax.test.scene.*
import com.baymax.test.scene.drawable.DrawableUtils
import com.baymax.test.scene.drawable.GradientShadow
import com.baymax.test.scene.drawable.InvlateDrawable
import com.baymax.test.scene.view.ReflectDrawable
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlin.random.Random

/**
 * @title: 标题
 * @project: TestScene
 * @package: com.baymax.test.scene.demo
 * @class: LineDrawableSscene
 * @description:
 *
 *
 * 类描述
 *
 *
 * @version: 1.0
 * @createDate: 2022/8/16 12:35
 * @Copyright (C) 2022 YSTEN
 * @author: xuyujian
 */
class DrawableScene : BaseScene() {
    override fun onCreateView(
        layoutInflater: LayoutInflater,
        viewGroup: ViewGroup,
        bundle: Bundle?
    ): View {
        return viewGroup.newSceneFlexContainer {
//            addView(getV(), ViewGroup.MarginLayoutParams(100, 100))
//            addView(getV(), ViewGroup.MarginLayoutParams(100, 100))

            addDFView<View>(200, 150) {
                val origin = ContextCompat.getDrawable(context, R.mipmap.ic_launcher)!!
                background = ReflectDrawable(origin as BitmapDrawable)
            }
            addDFView<View>(200, 150) {
                background = InvlateDrawable()
            }

            addDFView<View>(100, 300) {
                background = GradientShadow()
            }
            addButton("hello") {

            }

             addButton("text color use state list", {
                    setTextColor(ColorStateList.valueOf(0xff000000.toInt()))
             }){
                 isSelected = !isSelected
                 setTextColor(
                     ColorStateList(
                         arrayOf(
                             intArrayOf(android.R.attr.state_focused),
                             intArrayOf(android.R.attr.state_selected),
                             StateSet.WILD_CARD
                         ),
                         intArrayOf(Color.YELLOW, Color.BLUE, Color.BLACK)
                     )
                 )

            }


        }
    }


}
